LEAST_SQUARE calculates the least square fit of data to the curve of the form y = Γêæax^n for n = 0 to NMAX. NMAX is less than the number of data points.
TYPE REQUIREMENTS
const
MAXPOWER = the maximum power for the polynomial
MAXSIZE = A MAXIMUM SIZE FOR DATA ARRAY MUST BE GREATER THEN MAXPOWER
TYPE
FLOAT = REAL or DOUBLE or EXTENDED;
DATA = ARRAY[1..MAX NUMBER OF POINTS] of Float;
RAY = ARRAY [1..NMAX+1] OF FLOAT;
FIXXED = INTEGER of LONGINT;
CALLING PROCEDURE
var
X:DATA;{Array containing the independent variable}
Y:DATA;{Array containing the dependent variable}
NDP:FIXXED;{The number of data points}
COEF:RAY;{The output least square parameter of the above equation}
POWER:FLOAT;{NMAX in the above equation}
Define X, Y, NDP, POWER. Then call
LEAST_SQUARE(COEF,X,Y,NDP,POWER);.
On return COEF contains the coefients of the polynomial least square fit.
EXAMPLE
The example program reads in NDP, POWER, X, and Y from the keyboard and prints COEF.
REFERENCES
James, M. L., Smith, G. M., Wolford, J. C.: Applied Numerical Methods for Digital Computation With Fortran and CSMP, Harper and Row, New York, 1977.